<template>
  <el-dropdown @command="handleCommand">
    <span class="el-dropdown-link">
      操作<i class="el-icon-arrow-down el-icon--right" />
    </span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item command="add">添加子部门</el-dropdown-item>
      <el-dropdown-item command="edit">编辑部门</el-dropdown-item>
      <el-dropdown-item command="del">删除部门</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  name: 'Operate',
  props: {
    // 记录当前操作的是哪个部门
    node: {
      type: Object,
      default: () => {}
    }
  },
  methods: {
    handleCommand(command) {
      // switch (command) {
      //   case 'add':
      //     this.$emit('add-dept', this.node.id)
      //     break
      //   case 'edit':
      //     this.$emit('edit-dept', this.node.id)
      //     break
      //   case 'del':
      //     this.$emit('del-dept', this.node.id)
      //     break
      //   default:
      //     break
      // }
      this.$emit(`${command}-dept`, this.node.id)
    }
  }
}
</script>
